<template>
	<view class="adoptRecords">
		<view class="orderItem" v-for="item in orderList.lists" :key="item.id">
			<view class="order_info_top_box">
				<view class="order_sn">
					<span class="mar-right-10">订单编号</span>
					<span>{{item.id}}</span>
				</view>
				<view class="order_status">
					<span>剩余:{{item.remain_day}}天</span>
				</view>
			</view>
			<view class="order_info_center_box">
				<view class="order_goods_img">
					<image :src="item.cover" mode=""></image>
				</view>
				<view class="order_info_details">
					<view class="order_goods_item_name more-text2">{{item.order_name}}</view>
					<view class="order_goods_num">
						<view class="fn-sz-28 fn-cl-666666 mar-right-54">{{item.farm_product_option_name}}</view>
					</view>
				</view>
			</view>
			<view class="order_bottom_btn_box">
				<view class="parmary_btn"><button @tap="goDetails(item)">认养详情</button></view>
			</view>
		</view>
		<u-loadmore :status="loadMoreStatus" v-if="orderList.lists.length" />
	</view>
</template>

<script>
	import com from '../../mixin/index.js';
	export default {
		mixins: [com],
		data() {
			return {
				page: {
					page: 1,
					page_size: 10
				},
				orderList: {
					lists: [],
					total: 1,
					total_page: 0
				},
			};
		},
		onLoad() {
			this.getOrderList();
		},
		onReachBottom() {
			this.getOrderList();
		},
		onPullDownRefresh() {
			this.initGetList();
		},
		methods: {
			goDetails(val) {
				uni.navigateTo({
					url: `/pages/adoptRecords/adoptDetails?id=${val.id}`
				})
			},
			//初始化重新获取
			initGetList() {
				this.page = {
					page: 1,
					page_size: 10
				};
				this.orderList = {
					lists: [],
					total: 1,
					total_page: 0
				};
				this.getOrderList();
			},
			getOrderList() {
				let params = {
					...this.page
				};
				this.getList('orderList', 'getAdoptOrderList', 'page', params).then(res => {
					uni.stopPullDownRefresh();
				});
			}
		}
	}
</script>

<style lang="scss">
	.adoptRecords {
		padding: 20rpx 24rpx;
		min-height: 100vh;
		background-color: #F9F9F9;

		.orderItem {
			background: #ffffff;
			border-radius: 20rpx;
			padding: 32rpx 24rpx;
			margin-bottom: 20rpx;

			.order_info_top_box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-bottom: 28rpx;
				border-bottom: 1rpx dashed #cccccc;

				.order_sn {
					font-size: 28rpx;
					font-weight: 400;
					color: #666666;
				}

				.order_status {
					font-size: 30rpx;
					font-weight: 500;
					color: #222222;
				}
			}

			.order_info_center_box {
				display: flex;
				padding: 29rpx 0;
				border-bottom: 1rpx dashed #cccccc;

				.order_goods_img {
					flex: none;
					margin-right: 23rpx;

					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
					}
				}

				.order_info_details {
					flex: 1;

					.order_goods_item_name {
						font-size: 28rpx;
						font-weight: 400;
						color: #222222;
						margin-bottom: 55rpx;
					}

					.order_goods_num {}
				}
			}

			.order_bottom_btn_box {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				padding-top: 24rpx;

				view {
					margin-right: 20rpx;

					button {
						width: 150rpx;
						height: 58rpx;
						font-size: 24rpx;
						line-height: 58rpx;
						border-radius: 33rpx;
						padding: 0;
					}

					&:nth-last-child(1) {
						margin-right: 0rpx;
					}
				}
			}

			.parmary_btn {
				button {
					color: #222222;
					text-align: center;
					background: #ffffff;
					border-radius: 33rpx;
					border: 1rpx solid #cccccc;
				}
			}

		}
	}
</style>